﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using POSSystem.DAL;

namespace POSSystem.BLL
{
    public class Vouchers : _Vouchers
    {
        public static void DeleteByIds(string ids)
        {
            Vouchers vc = new Vouchers();
            vc.Where.ID.Value = ids;
            vc.Where.ID.Operator = MyGeneration.dOOdads.WhereParameter.Operand.In;
            vc.Query.Load();

            for (int i = 0; i < vc.RowCount; i++)
            {
                vc.Deleted = true;
                vc.MoveNext();
            }

            vc.Save();
        }

        public static void SetActive(Guid id)
        {
            Vouchers vc = new Vouchers();
            vc.Where.ID.Value = id;
            vc.Query.Load();

            for (int i = 0; i < vc.RowCount; i++)
            {
                vc.Active = !vc.Active;
                vc.MoveNext();
            }

            vc.Save();
        }

        public static Vouchers GetByIds(string ids)
        {
            Vouchers vc = new Vouchers();
            vc.Where.ID.Value = ids;
            vc.Where.ID.Operator = MyGeneration.dOOdads.WhereParameter.Operand.In;
            vc.Query.Load();

            return vc;
        }

        public static Vouchers GetByCode(string code)
        {
            Vouchers vc = new Vouchers();
            vc.Where.Code.Value = code;
            vc.Where.Deleted.Value = false;
            vc.Query.Load();

            return vc;
        }
    }
}
